package com.bw.mapper;

import com.bw.bean.Vo;
import com.bw.bean.Vo1;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface VoMapper {
    @Select("select sum(amount) from order_info where date (create_time)='2023-01-06'")
    Double getList1();

    @Select("select bd.name 'name',\n" +
            "       sum(oi.amount) 'value'\n" +
            "from order_info oi\n" +
            "left join order_cargo oc on oi.id = oc.order_id\n" +
            "left join base_dic bd on bd.id = oc.cargo_type\n" +
            "group by bd.name")
    List<Vo> getList2();

    @Select("select bo.org_name 'name',\n" +
            "       sum(tt.actual_distance) 'lc',\n" +
            "       count(tt.id) 'num',\n" +
            "       sum(timestampdiff(second ,actual_start_time,actual_end_time)) 'time',\n" +
            "       sum(timestampdiff(second ,actual_start_time,actual_end_time))/count(tt.id) 'avgTime',\n" +
            "       sum(tt.actual_distance)/count(tt.id) 'avgLc'\n" +
            "from transport_task tt\n" +
            "left join line_base_info lbi on lbi.id = tt.line_id\n" +
            "left join base_organ bo on bo.id = lbi.org_id\n" +
            "group by bo.org_name")
    List<Vo1> getList3();

    @Select("select bri1.name 'name',\n" +
            "       count(ttd.id) 'value'\n" +
            "from transport_task_detail ttd\n" +
            "left join transport_task tt on tt.id = ttd.transport_task_id\n" +
            "left join line_base_info lbi on lbi.id = tt.line_id\n" +
            "left join base_organ bo on bo.id = lbi.org_id\n" +
            "left join base_region_info bri on bri.id = bo.region_id\n" +
            "left join base_region_info bri1 on bri1.id = bri.parent_id\n" +
            "group by bri1.name")
    List<Vo> getList4();
}
